<%@ page language="java" import="java.util.*, java.text.*,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.shhd.manager.*, com.zjut.zs.shhd.dao.*,com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*,
com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.an.config.manager.*, com.zjut.an.config.dao.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/plugins/webupload/css/upload/upload.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/plugins/webupload/plugin/ueditor/third-party/webuploader/webuploader.css">				
<script type="text/javascript" src="../plugins/assets/plugins/jquery-3.5.1.min.js"></script>
<script src="<%=request.getContextPath() %>/plugins/webupload/plugin/ueditor/third-party/webuploader/webuploader.min.js"></script>
</head>
<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null&&session.getAttribute("user") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);
//if(Status.ON.getStatus().equals(school.getScShhdActive())){ //是否上传
//	out.print("<script>window.location='zs_shhd.jsp';</script>");
//	out.close();
//	return;
//}

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsShhdManager xmanager = (ZsShhdManager) SpringContextUtil.getBean("ZsShhdManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsUserStatusManager smanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsShhd shhd = new ZsShhd();
ZsUser user = null;
if((session.getAttribute("admin")!=null||session.getAttribute("user")!=null) && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");	
} 	
String url = "&usId="+user.getUsId();
List list = new ArrayList();
if (user!=null) {
	shhd.setZsUser(user);
	list = xmanager.getDataByInstance(1,100,"hdId","asc",shhd).getObjects();
}
if(request.getParameter("hdId")!=null) {
	shhd = xmanager.getData(request.getParameter("hdId"));				
}	
ZsUserStatus userStatus = smanager.getDataByUser(user);
boolean edit=false;//允许编辑
//未确认，被退回允许编辑
if(Status.APPSTATUS_NULL.getStatus().equals(userStatus.getAppStatus()) || Status.APPSTATUS_NO.getStatus().equals(userStatus.getAppStatus()) || Status.APPSTATUS_NOTIME.getStatus().equals(userStatus.getAppStatus()))edit=true;
//如果材料填写截止或报考信息填写截止，不允许编辑
if(!Status.ON.getStatus().equals(school.getScAppActive()) || Status.OFF.getStatus().equals(school.getScShhdActive()) || Status.HIDDEN.getStatus().equals(school.getScShhdActive()) )edit=false;
 %>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="#">社会活动情况</a></li>
    </ul>
    			
    </div>
    <div class="formbody">    
	    <div class="rightinfo">
		    <table class="imgtable">
		    <thead>
		    <tr>
		    <th>活动名称</th>
		    <th>担任角色</th>
		    <th>活动时间</th>
		    <th>组织单位</th>
		    <th>操作</th>
		    </tr>
		    </thead>
		    
		    <tbody>
		    <%
		    for (int i=0; i<list.size(); i++){
		    	ZsShhd obj = (ZsShhd)list.get(i);
		     %>
		    <tr>
		    <td><%=obj.getHdName() %></td>
		    <td><%=obj.getHdJs() %></td>
		    <td><%=obj.getHdDateStart() %>至<%=obj.getHdDateEnd() %></td>
		    <td><%=obj.getHdOrg() %></td>
		    <td>
		    <%if(edit){ %>
		    <a href="zs_shhd.jsp?hdId=<%=obj.getHdId()%><%=url %>" class="tablelink">编辑</a>　
			<a href="#" onclick="javascript:deleteobj('<%=obj.getHdId() %>');">删除</a>
		    <%} %>
		    </td>
		    </tr>
		    <% }  %>
		    
		    </tbody>
		    </table>
	    
	    	<br>
		     
		    <%if(edit){ %>		
		    <form id="ff" name="add" role="form" class="form-horizontal" action="" method="post">
		    <table id="hdtable" class="imgtable" >
		    <thead>
		    <tr>
		    <th>活动名称</th>
		    <th>担任角色</th>
		    <th>活动开始时间</th>
		    <th>活动结束时间</th>
		    <th>组织单位</th>
		    </tr>
		    </thead>
		    
		    <tbody>
		    <tr>
		    <td style="text-indent: 5px;"><input id="hdName" name="hdName" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdName()) %>" required style="width: 100px"/></td>
		    <td style="text-indent: 5px;"><input id="hdJs" name="hdJs" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdJs()) %>" style="width: 100px"/></td>
		    <td style="text-indent: 5px;"><input id="hdDateStart" name="hdDateStart" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdDateStart()) %>" style="width: 100px"/></td>
		    <td style="text-indent: 5px;"><input id="hdDateEnd" name="hdDateEnd" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdDateEnd()) %>" style="width: 100px"/></td>
		    <td style="text-indent: 5px;"><input id="hdOrg" name="hdOrg" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdOrg()) %>" required style="width: 200px"/></td>
		    </tr>
		    </tbody>
		    </table>
				<input id="hdId" name="hdId" type="text" class="dfinput" value="<%if(null==shhd.getHdId()){out.print("");}else{out.print(shhd.getHdId());}; %>" style="display:none;"/>
		    	<input id="zsUser.usId" name="zsUser.usId" type="text" class="dfinput" value="<%=shhd.getZsUser().getUsId()%>" style="display:none;"/>
				<input name="hdFiles" type="text" id="hdFiles" value="<%=html.getInputString(shhd.getHdFiles()) %>"  class="dfinput"  style="display:none;"/>  	
				    <!--用来存放文件信息-->
				    
				    <div class="btns">	
						<button type="submit" class="btn btn-primary btn-sm" style="float:right;margin:10px;">确认保存</button>	
				    </div>
		    </form>
		    <%} %>
	    </div>
    
    </div>
 <div style="margin:50px;"><%out.print(anconfig.getSingleConfigInfoByName("社会活动填写需知")); %></div>
 
<script src="../plugins/assets/plugins/jquery-3.5.1.min.js" type="text/javascript"></script>  
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.validate.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.metadata.js" type="text/javascript"></script>
<script src="../admin/js/publicManager.js" type="text/javascript" charset="utf-8"></script> 

		<script type="text/javascript">
		var updateOneAction = '../zsShhdSave.action?randnum='+Math.floor(Math.random()*1000000);
			var loactionurl = 'zs_shhd.jsp?<%=url%>';
			
		$(function(){
		    //jquery.validate
			$("#ff").validate({
				submitHandler: function() {
					//验证通过后 的js代码写在这里
					submitFormAdvance();
				}
			})				
		})
		
		$('.imgtable tbody tr:odd').addClass('odd');
		
		function deleteobj(hdId) {
			if (confirm("是否确认"))  { 
				$.get("../zsShhdDelete.action?randnum="+Math.floor(Math.random()*1000000)+"&hdId="+hdId, function(data){
					if(data.flag=="success"){
						alert("删除成功！");
						window.location = loactionurl;
					}else{
						alert("删除失败！");
					}
				}); 
			}
		}
		</script>
		<script src="js/laydate.dev.js" type="text/javascript"></script>
		<script type="text/javascript">			
			laydate({
				elem: document.getElementById("hdDateStart")
			});
			laydate({
				elem: document.getElementById("hdDateEnd")
			});
		</script>
		
<%} %>
</body>

</html>
